<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul>
        <li id="one">我是li标签</li>
        <li id="two">我是li标签</li>
        <li id="three">我是li标签</li>
    </ul>
    <script>
        var item1 = document.querySelectorAll('li')[0];
        var item2 = document.querySelectorAll('li')[1];
        var item3 = document.querySelectorAll('li')[2];
        var ul = document.querySelector('ul');
        // item1.onclick = function(){
        //   this.innerHTML = 'hello html'
        // }
        // item2.onclick = function(){
        //   this.innerHTML = 'hello css'
        // }
        // item3.onclick = function(){
        //   this.innerHTML = 'hello js'
        // }

        ul.onclick = function () {
            // console.log(event.target);
            switch (event.target.id) {
                case 'one':
                    event.target.innerHTML = 'hello html';
                    break;
                case 'two':
                    event.target.innerHTML = 'hello css';
                    break;
                case 'three':
                    event.target.innerHTML = 'hello js';
                    break;
                default:
                    event.target.innerHTML = '错误'
            }
        }

    </script>
</body>

</html>